23#if __has_include(<boost/assert/source_location.hpp>)
24#include <boost/assert/source_location.hpp>
28#include "spdlog/spdlog.h"
29#include "spdlog/async.h"
30#include "spdlog/sinks/stdout_color_sinks.h"
33#include "spdlog/fmt/ostr.h"
42namespace do_not_enter_where_the_wolf_lives
44#define __INTERNAL_WOLF_MAIN_LOGGER_NAME_ "wolf_main_console"
56 "{}{}{}{}{}{}{}{}{}{}",
57 "{}{}{}{}{}{}{}{}{}{}{}",
58 "{}{}{}{}{}{}{}{}{}{}{}{}",
59 "{}{}{}{}{}{}{}{}{}{}{}{}{}",
60 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
61 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
62 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
63 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
64 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
65 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
66 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
67 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
68 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
69 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
70 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
71 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
72 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
73 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
74 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
75 "{}{}{}{}{}{}{}{}{}{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{}{}{}{}{}{}{}{}",
89 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
90 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
91 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
92 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
93 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
94 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
95 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",
96 "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}");
105 Logger(
const std::string& name);
107 Logger(std::string&& name);
117 template <
typename... Args>
118 void info(Args&&... args)
const;
120 template <
typename... Args>
121 void warn(Args&&... args)
const;
123 template <
typename... Args>
124 void error(Args&&... args)
const;
126 template <
typename... Args>
127 void debug(Args&&... args)
const;
129 template <
typename... Args>
130 void trace(Args&&... args)
const;
148 console_->set_level(spdlog::level::trace);
153 spdlog::init_thread_pool(4096, 1);
181 console_->set_level(spdlog::level::trace);
186 spdlog::init_thread_pool(4096, 1);
213template <
typename... Args>
216#if FMT_VERSION >= 90000
217 console_->info(std::get<
sizeof...(args) - 1>(
repeated_brace), fmt::streamed(std::forward<Args>(args))...);
223template <
typename... Args>
226#if FMT_VERSION >= 90000
227 console_->warn(std::get<
sizeof...(args) - 1>(
repeated_brace), fmt::streamed(std::forward<Args>(args))...);
233template <
typename... Args>
236#if FMT_VERSION >= 90000
237 console_->error(std::get<
sizeof...(args) - 1>(
repeated_brace), fmt::streamed(std::forward<Args>(args))...);
243template <
typename... Args>
246#if FMT_VERSION >= 90000
247 console_->debug(std::get<
sizeof...(args) - 1>(
repeated_brace), fmt::streamed(std::forward<Args>(args))...);
253template <
typename... Args>
256#if FMT_VERSION >= 90000
257 console_->trace(std::get<
sizeof...(args) - 1>(
repeated_brace), fmt::streamed(std::forward<Args>(args))...);
265 bool p2 = q_size % 2 == 0;
267 if (p2) spdlog::init_thread_pool(q_size, 1);
285 bool exists(
const std::string& name)
const
287 std::lock_guard<std::mutex> lock(
mut_);
293 std::lock_guard<std::mutex> lock(
mut_);
327#define WOLF_STRINGIFY(x) #x
328#define WOLF_STR_HELPER(x) WOLF_STRINGIFY(x)
345#define WOLF_ASYNC_QUEUE_LOG_NAMED(name, ...) \
346 wolf::internal::WolfLoggerManager::get().getLogger(name).set_async_queue(x);
348#define WOLF_INFO_NAMED(name, ...) \
350 char this_file[] = __FILE__; \
351 wolf::internal::WolfLoggerManager::get().getLogger(name).info( \
352 "[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
354#define WOLF_INFO_NAMED_COND(name, cond, ...) \
355 if (cond) WOLF_INFO_NAMED(name, __VA_ARGS__);
357#define WOLF_WARN_NAMED(name, ...) \
359 char this_file[] = __FILE__; \
360 wolf::internal::WolfLoggerManager::get().getLogger(name).warn( \
361 "[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
363#define WOLF_WARN_NAMED_COND(name, cond, ...) \
364 if (cond) WOLF_WARN_NAMED(name, __VA_ARGS__);
366#define WOLF_ERROR_NAMED(name, ...) \
368 char this_file[] = __FILE__; \
369 wolf::internal::WolfLoggerManager::get().getLogger(name).error( \
370 "[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
372#define WOLF_ERROR_NAMED_COND(name, cond, ...) \
373 if (cond) WOLF_ERROR_NAMED(name, __VA_ARGS__);
376#define WOLF_DEBUG_NAMED(name, ...) \
379 char this_file[] = __FILE__; \
380 wolf::internal::WolfLoggerManager::get().getLogger(name).debug( \
381 "[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
383#define WOLF_DEBUG_NAMED_COND(name, cond, ...) \
386 if (cond) WOLF_DEBUG_NAMED(name, __VA_ARGS__); \
389#define WOLF_DEBUG_NAMED(name, ...) \
393#define WOLF_DEBUG_NAMED_COND(name, cond, ...) \
400#define WOLF_TRACE_NAMED(name, ...) \
403 char this_file[] = __FILE__; \
404 wolf::internal::WolfLoggerManager::get().getLogger(name).trace( \
405 "[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
407#define WOLF_TRACE_NAMED_COND(name, cond, ...) \
410 if (cond) WOLF_TRACE_NAMED(name, __VA_ARGS__); \
413#define WOLF_TRACE_NAMED(name, ...) \
417#define WOLF_TRACE_NAMED_COND(name, cond, ...) \
425#define WOLF_ASYNC_QUEUE_LOG(x) wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_).set_async_queue(x);
427#define WOLF_INFO(...) \
429 char this_file[] = __FILE__; \
430 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
431 .info("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
433#define WOLF_INFO_COND(cond, ...) \
434 if (cond) WOLF_INFO(__VA_ARGS__);
436#define WOLF_WARN(...) \
438 char this_file[] = __FILE__; \
439 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
440 .warn("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
442#define WOLF_WARN_COND(cond, ...) \
443 if (cond) WOLF_WARN(__VA_ARGS__);
445#define WOLF_ERROR(...) \
447 char this_file[] = __FILE__; \
448 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
449 .error("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
451#define WOLF_ERROR_COND(cond, ...) \
452 if (cond) WOLF_ERROR(__VA_ARGS__);
455#define WOLF_DEBUG(...) \
458 char this_file[] = __FILE__; \
459 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
460 .debug("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
462#define WOLF_DEBUG_COND(cond, ...) \
465 if (cond) WOLF_DEBUG(__VA_ARGS__); \
468#define WOLF_DEBUG(...) \
472#define WOLF_DEBUG_COND(cond, ...) \
479#define WOLF_TRACE(...) \
482 char this_file[] = __FILE__; \
483 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
484 .trace("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
486#define WOLF_TRACE_COND(cond, ...) \
489 if (cond) WOLF_TRACE(__VA_ARGS__); \
492#define WOLF_TRACE(...) \
496#define WOLF_TRACE_COND(cond, ...) \
503#define WOLF_PROC_DEBUG(...) WOLF_DEBUG(__VA_ARGS__)
505#if __has_include(<boost/assert/source_location.hpp>)
506#define WOLF_PROC_DEBUG(...) \
508 static_assert(std::is_base_of<ProcessorBase, typename std::remove_pointer<decltype(this)>::type>::value, \
509 "WOLF_PROC_DEBUG can only be used in processors"); \
511 bool called_from_derived = std::string(boost::source_location(BOOST_CURRENT_LOCATION).function_name()) \
512 .rfind("wolf::" + getType() + "::") == 0; \
514 if (debug_verbose_level_ == "all" or (called_from_derived and (debug_verbose_level_ == "derived")) or \
515 (not called_from_derived and (debug_verbose_level_ == "base"))) \
518 char this_file[] = __FILE__; \
519 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
520 .debug("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
524#define WOLF_PROC_DEBUG(...) \
526 static_assert(std::is_base_of<ProcessorBase, typename std::remove_pointer<decltype(this)>::type>::value, \
527 "WOLF_PROC_DEBUG can only be used in processors"); \
529 if (debug_verbose_level_ != "none") \
531 char this_file[] = __FILE__; \
532 wolf::internal::WolfLogger::get(__INTERNAL_WOLF_MAIN_LOGGER_NAME_) \
533 .debug("[", basename(this_file), " L", __LINE__, "] ", __FUNCTION__, ": ", __VA_ARGS__); \
539#define WOLF_PROC_DEBUG_COND(cond, ...) \
540 if (cond) WOLF_PROC_DEBUG(__VA_ARGS__);
A thread-safer (?) Singleton implementation with argument forwarding.
Definition: singleton.h:33
Definition: logging.h:280
bool exists(const std::string &name) const
Definition: logging.h:285
const Logger & getLogger(const std::string &name)
Definition: logging.h:291
bool addLogger(const std::string &name)
Definition: logging.h:305
std::map< const std::string, const LoggerPtr > logger_map_
Definition: logging.h:303
std::mutex mut_
Definition: logging.h:301
bool existsImpl(const std::string &name) const
Definition: logging.h:313
Definition: logging.h:103
void error(Args &&... args) const
Definition: logging.h:234
void info(Args &&... args) const
Definition: logging.h:214
void operator=(Logger &)=delete
Logger(const std::string &name)
Definition: logging.h:142
void set_pattern(const std::string &p)
Definition: logging.h:272
void debug(Args &&... args) const
Definition: logging.h:244
bool set_async_queue(const std::size_t q_size)
Definition: logging.h:263
~Logger()
Definition: logging.h:208
const std::string log_name_
Definition: logging.h:137
void operator=(Logger &&)=delete
void trace(Args &&... args) const
Definition: logging.h:254
void warn(Args &&... args) const
Definition: logging.h:224
std::shared_ptr< spdlog::logger > console_
Definition: logging.h:139
#define __INTERNAL_WOLF_MAIN_LOGGER_NAME_
Definition: logging.h:44
static constexpr auto repeated_brace
Definition: logging.h:46
std::unique_ptr< Logger > LoggerPtr
Definition: logging.h:277
Definition: capture_base.h:23